<template>
    <div class="">
        <pagetitle type="2"></pagetitle>
        <el-card class="box-card">
            <div class="teamTopTip">
                <el-icon color="#252B3A" size="16px"><Warning /></el-icon>
                <div class="tipbox">
                    <div class="tiptitle">温馨提示</div>
                    <div class="tipitem">
                        当前个人账户下您有 10 个团队名额，加入团队 已使用 2 个，创建团队 已使用 1 个，已冻结 0 个。
                        <el-button type="primary" size="small" link>申请升级</el-button>
                    </div>
                    <div class="tipitem">
                        如果您要加入已经注册成功的团队，个人实名认证 成功后，请点击
                        <el-button type="primary" size="small" link @click="topages('/team/myteams/jointeam')">加入团队</el-button>
                    </div>
                    <div class="tipitem">
                        如果您是企业法人或者法人授权人，个人实名认证 成功后，您可以 注册新的团队，请点击
                        <el-button type="primary" size="small" link @click="topages('/team/myteams/teammsg?type=1')">创建团队</el-button>
                    </div>
                </div>
            </div>
        </el-card>
        <el-card class="operatingrecord">
            <template #header>
                <div class="serchbox">
                    <div class="left">
                        <div class="item">
                            <el-input v-model="queryData.keyWords" class="serchs" @input="paginaClick(1)" placeholder="通过名称搜索团队">
                                <template #suffix>
                                    <el-icon class="el-input__icon"><search /></el-icon>
                                </template>
                            </el-input>
                        </div>
                        <sxnfbtn @click="paginaClick(1)">搜索</sxnfbtn>
                        <!-- <el-button type="primary" text bg @click="paginaClick(1)">搜索</el-button> -->
                        <span>*搜索范围：团队名称</span>
                    </div>
                    <!-- <el-button type="primary" text bg>新增客户</el-button> -->
                </div>
            </template>
            <el-table :data="pageData.list" style="width: 100%" border>
                <el-table-column label="序号" width="50">
                    <template #default="scope">
                        {{ scope.$index + 1 }}
                    </template>
                </el-table-column>
                <el-table-column label="创建时间" prop="createTime" width="150"></el-table-column>
                <el-table-column label="团队名称" prop="nameForShort" width="200"></el-table-column>
                <el-table-column label="法人" prop="legalPersonName" width="110"></el-table-column>
                <el-table-column label="组织机构类型" prop="type" width="200"> </el-table-column>
                <el-table-column label="团队产业分类" prop="createTime">
                    <template #default="scope">
                        {{ scope.row.classify.join("/") }}
                    </template>
                </el-table-column>
                <el-table-column label="团队注册地址" prop="createTime">
                    <template #default="scope">
                        {{ scope.row.address ? scope.row.address.valueText : "" }}
                    </template>
                </el-table-column>
                <el-table-column label="认证状态" prop="createTime" width="80">
                    <template #default="scope">
                        {{ scope.row.certified == 1 ? "认证中" : scope.row.certified == 2 ? "已认证" : "未认证" }}
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="80">
                    <template #default="scope">
                        <el-button type="primary" size="small" link @click="addTeams(scope.row)">详细</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination :totalNum="pageData.total" @paginaClick="paginaClick"></pagination>
        </el-card>
    </div>
</template>
<script lang="ts" setup>
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
import { getAllTeamList } from "@/api/team";
const router = useRouter();
// const tableData = ref([{}]);
// const input = ref("");
const pageData: any = reactive({
    list: [],
    total: 0,
});
const queryData = reactive({
    pageNum: 1,
    pageSize: 10,
    keyWords: "",
});
// 获取团队列表
const getTeamList = () => {
    getAllTeamList(queryData).then((res: any) => {
        pageData.list = res.data.list;
        pageData.total = res.data.total;
        pageData.list.forEach((v: any) => {
            v.classify = [];
            if (v.address) {
                v.address = JSON.parse(v.address);
            }
            v.industrialClassificationList.forEach((i: any) => {
                v.classify.push(i.industrialName);
            });
        });
    });
};

getTeamList();
// 分页
const paginaClick = (val: number) => {
    queryData.pageNum = val;
    getTeamList();
};

const addTeams = (row: any) => {
    router.push(`/team/myteams/teammsg?id=${row.teamId}&type=4`);
};
const topages = (url: string) => {
    router.push(url);
};
</script>
<style lang="scss" scoped>
.teamTopTip {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    .tipbox {
        margin-left: 10px;
        .tiptitle {
            font-size: 14px;
            color: #252b3a;
        }
        .tipitem {
            margin-top: 10px;
            font-size: 14px;
            color: #252b3a;
            display: flex;
            align-items: center;
        }
    }
}

.operatingrecord {
    margin-top: 20px;
    .serchbox {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .left {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            .item {
                margin-right: 20px;
                color: #333333;
                font-size: 12px;
                .serchs {
                    width: 300px;
                }
            }
            span {
                color: #999999;
                font-size: 12px;
                margin-left: 10px;
            }
        }
    }
}
</style>
